/********************************************
 * 功能说明: TenantEmployee实体类对应的基础业务Repository
 * 模块名称:
 * 系统名称:
 * 软件版权: Frank
 * 系统版本: 1.0.0.1
 * 开发人员:
 * 开发时间: 2019-12-18 18:41:08
 * 审核人员:
 * 相关文档:
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.uaa.repository;

import com.spring.arch.uaa.model.Tenant;
import com.spring.arch.uaa.model.TenantEmployee;
import com.spring.arch.uaa.model.Tenant;
import com.spring.arch.uaa.model.TenantEmployee;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

/**
 * TenantEmployee实体类对应的基础业务Repository
 *
 * @author
 * @version 1.0.0.1
 * @since 2019-12-18 18:41:08
 */
@org.springframework.stereotype.Repository
public interface TenantEmployeeRepository extends Repository<TenantEmployee, UUID>,
        QuerydslPredicateExecutor<TenantEmployee> {

    TenantEmployee save(TenantEmployee model);

//    TenantEmployee saveAndFlush(TenantEmployee model);

    Optional<TenantEmployee> findById(UUID id);

    Page<TenantEmployee> findAll(Pageable pageable);

    void delete(TenantEmployee tenantEmployee);

    Optional<TenantEmployee> findByCodeAndTenantId(String code, UUID tenantId);

    boolean existsByCodeAndTenant(String code, Tenant tenant);

    boolean existsByMobileAndTenant(String mobile, Tenant tenant);

    boolean existsByMobileAndTenantAndCodeNotLike(String mobile, Tenant tenant, String prefix);

    boolean existsByCodeAndTenantAndIdNot(String name, Tenant tenant, UUID id);

    boolean existsByMobileAndTenantAndIdNot(String mobile, Tenant tenant, UUID id);

    boolean existsByMobileAndTenantAndIdNotAndCodeNotLike(String mobile, Tenant tenant, UUID id, String prefix);

    TenantEmployee findByCode(String code);

    TenantEmployee findByMobileAndTenantId(String mobile, UUID uuid);

    List<TenantEmployee> findByMobile(String mobile);
}

